<?php

use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;

class CreateUserCertTable extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    addCustomColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Any other destructive changes will result in an error when trying to
     * rollback the migration.
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('user_cert', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '资格证表']);

        //添加数据字段
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '用户资格证ID'])
            ->addColumn('user_cert_category_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '所属资格证分类id'])
            ->addColumn('step_sku_ids', 'text', ['null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM,'comment' => '工序SKU ID列表'])
            ->addColumn('step_attribute_config', 'json', ['null' => true, 'comment' => '选择的属性配置'])
            ->addColumn('base_man_hour', 'char', ['default' => '0', 'limit' => 36, 'comment' => '月基本工时'])
            ->addColumn('level', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '所属级别'])
            ->addColumn('level_category', 'enum', ['values' => 's,a,b,c', 'default' => 'c', 'comment' => '所属级别分类'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间']);

        //执行创建
        $table->create();
    }
}
